Eddie's Lessons
Beginners Programming
Reviewing the Stylebits Parameters
The four parameters of stylebits are AddBit, RemoveBit, AddExtendedBit, RemoveExtendedBit. For a review of these four parameters, and an introduction to Stylebits in general, please read [Stylebits Corner - An Introduction]. For examples of stylebits changing the appearance and input of textboxes, see [Stylebits Corner - Textboxes].
Stylebits and Formatted Text
Many of the stylebits commands used with windows and textboxes can also be used with statictext controls. Since statictext doesn't accept user input, most of the stylebits effects involve text formatting and borders. Statictext can be justified horizontally using these commands-
_ES_LEFT _ES_CENTER _ES_RIGHT
Statictext can also be centered vertically using the command -
_SS_CENTERIMAGE
It is possible to create a nice etched look in your text using the command
_WS_DISABLED
Use this strategy with caution, though. Any control disabled with the stylebits will require an API call to cause the statictext to later become enabled. The same look can be achieved using the native Liberty BASIC command !Disable and affords the programmer the opportunity to normalize the text look using !Enable later in the code. There are, however, some very interesting visual effects that can be achieved using a stylebits created border around your statictext. These are just some examples. With experimentation, you may find more.
| Stylebits | Border / Background Effect |
|---|---|
| _WS_BORDER, 0, 0, 0 | Thin Line Border |
| _WS_DLGFRAME, 0, 0, 0 | Raised Background |
| _WS_DLGFRAME, 0, 0, 0 | Recessed Background |
| 0, 0, _WS_EX_CLIENTEDGE , 0 | Recessed Disabled |
| 0, 0, _WS_EX_STATICEDGE or _WS_EX_CLIENTEDGE, 0 | Double Recessed Edge |
| 0, 0, _WS_EX_DLGMODALFRAME or _WS_EX_CLIENTEDGE, 0 | Raised Frame |
| _WS_THICKFRAME, 0, _WS_EX_DLGMODALFRAME _ or _WS_EX_CLIENTEDGE , 0 | Thicker Raised Frame |
| _WS_DISABLED, 0, 0, 0, 0 | Flat Disabled Background |
Stylebits and API Calls
Stylebits allow statictext to display images, but only when accompanied by an API call to user32.dll (SendMessageA). For an indepth explanation of placing images on statictext controls, see [Tip Corner - Images on Statictext!]. by [Alyce Watson]. The height and width of the statictext will initially change when the bitmap is loaded, but resizing the window will cause a smaller bitmap to stretch and fill the originally defined statictext dimensions. You can prevent this distortion by either making certain the statictext width and height is the same as the loaded bitmap or using the _SS_CENTERIMAGE stylebits. Recessed, raised and flat effects can be achieved using window edge stylebits.

The Stylebits Corner Series
What else can be done with stylebits? In the coming months the STYLEBITS command will be used to, among other things,
Eager to try Stylebits with buttons and other window controls? Can't wait for the next newsletter? Good news! The best way to explore and assign stylebit commands is with the Stylebits Wizard option found in Alyce Watson's [Liberty BASIC Workshop].
DEMO
The file stylebitsDemo4.bas is included in the zipped archive of this newsletter.
Eddie's Lessons
Beginners Programming